package org.example.scenicspot.service;

import org.example.scenicspot.domain.ScenicSpot;
import org.example.scenicspot.persistence.scenicSpotMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class scenicSpotService {
    @Autowired
    scenicSpotMapper scenicSpotMapper;
    public List<ScenicSpot> showscenicSpot(){
        return scenicSpotMapper.selectAll();
    }
    public List<ScenicSpot> searchscenicSpot(String keyword){
        return scenicSpotMapper.selectByName(keyword);
    }
    public ScenicSpot searchscenicSpotbyID(int id){
        return scenicSpotMapper.selectByID(id);
    }
    public void deletescenicSpot(int id){
        scenicSpotMapper.deleteById(id);
    }
    public void insertscenicSpot(ScenicSpot scenicSpot){
        scenicSpotMapper.insert(scenicSpot.getId(),scenicSpot.getName(),scenicSpot.getMaxCapacity(),scenicSpot.getParkingLotCapacity(),scenicSpot.getGeographicLocation(),scenicSpot.getElectronicMapURL(),scenicSpot.getScore());
        System.out.println(scenicSpot.getGeographicLocation());
    }

    public void updatescenicSpot(ScenicSpot scenicSpot){
        scenicSpotMapper.update(scenicSpot.getId(),scenicSpot.getName(),scenicSpot.getMaxCapacity(),scenicSpot.getParkingLotCapacity(),scenicSpot.getGeographicLocation(),scenicSpot.getElectronicMapURL(),scenicSpot.getScore());
    }
    public void updateScore(ScenicSpot scenicSpot){
        scenicSpotMapper.updateScore(scenicSpot.getId(),scenicSpot.getScore());
    }
}
